#include "DM.h"
#include "message.h"

//----------------------------------------------------------------------------------------------------------//
Inst_C::Inst_C(string p_strName,LibCell_C* p_pLibCell) : 
    _nId(), _strName(p_strName), _pLibCell(p_pLibCell), _vFromPinNode(), _pToPinNode(), _vDriver(), _vReceiver()
{
}
//----------------------------------------------------------------------------------------------------------//
bool Inst_C::isSeq() const
{
    return this->_pLibCell->is_seq();
}
//----------------------------------------------------------------------------------------------------------//
void Inst_C::dump(Dumper* p_pDumper)
{
    //inst_name cell_name
    if(this->isSeq()){
        p_pDumper->write("%s %s (%d/FF)\n",this->getName().c_str(),this->getLibCell()->getName().c_str(),this->getId());
    } else {
        p_pDumper->write("%s %s (%d)\n",this->getName().c_str(),this->getLibCell()->getName().c_str(),this->getId());
    }
    //drivers
    p_pDumper->write("drivers: ");
    for(unsigned int i=0;i<this->getDriver().size();++i){
        if(this->getDriver()[i]->isSeq()){
            p_pDumper->write("%s(%d/FF) ",this->getDriver()[i]->getName().c_str(),this->getDriver()[i]->getId());
        } else {
            p_pDumper->write("%s(%d) ",this->getDriver()[i]->getName().c_str(),this->getDriver()[i]->getId());
        }
    }
    p_pDumper->write("\n");
    //receivers
    p_pDumper->write("receivers: ");
    for(unsigned int i=0;i<this->getReceiver().size();++i){
        if(this->getReceiver()[i]->isSeq()){
            p_pDumper->write("%s(%d/FF) ",this->getReceiver()[i]->getName().c_str(),this->getReceiver()[i]->getId());
        } else {
            p_pDumper->write("%s(%d) ",this->getReceiver()[i]->getName().c_str(),this->getReceiver()[i]->getId());
        }
    }
    p_pDumper->write("\n");
    p_pDumper->write("\n");
}
//----------------------------------------------------------------------------------------------------------//
void Inst_C::dumpLibCell(Dumper* p_pDumper)
{
    p_pDumper->write("%s %s\n",this->getName().c_str(),this->getLibCell()->getName().c_str());
}
//----------------------------------------------------------------------------------------------------------//



